<?php
namespace App\Model\Appfc114;

//use PhalApi\Model\NotORMModel as NotORM;
use Illuminate\Database\Eloquent\Model as Model;
use Illuminate\Database\Capsule\Manager as DB;

class News extends Model {

    protected $table = "web_contentindex";
    public $timestamps = false;


    public function getDetail($id, $index, $field ="web_contentindex.id"){
        $row = $this
            ->leftJoin("web_content".$index,"web_contentindex.id","=","web_content".$index.".id")
            ->where($field,$id)
            ->first();
        return $row;
    }

    public function getListItems($where,$whereRaw,$index, $limitdata, $order) {
        //如需打印sql 需开启DB执行日志
        // DB::connection()->enableQueryLog();
        $data = $this
            ->leftJoin("web_content".$index,"web_contentindex.id","=","web_content".$index.".id")
            ->where($where)
            ->whereRaw($whereRaw)
            ->orderByRaw($order)
            ->skip($limitdata["offset"])
            ->take($limitdata["limit"])
            ->get(["web_contentindex.*","web_content".$index.".*"]);
        //打印sql
         //print_r(DB::getQueryLog());exit;
        return $data;
    }

}
